<template>
    <div class="app-container">

        <template>

            <div class="app-container">

                <h2 style="text-align: center;">订单详细信息</h2>

                <div class="ccInfo ">
                    <div>
                        <img :src="orderInfo.cover">
                    </div>
                    <div class="main">
                        <el-descriptions class="margin-top" :column="1" :size="medium">
                            <el-descriptions-item label="订单编号">{{ orderInfo.orderNo }}</el-descriptions-item>
                            <el-descriptions-item label="课程名称">{{ orderInfo.title }}</el-descriptions-item>
                            <el-descriptions-item label="老师名称">{{ orderInfo.teacherName }}</el-descriptions-item>
                            <el-descriptions-item label="买家名称">{{ orderInfo.nickname }}</el-descriptions-item>
                            <el-descriptions-item label="买家联系方式">{{ orderInfo.mobile }}</el-descriptions-item>



                            <el-descriptions-item label="支付金额">{{ orderInfo.price }}</el-descriptions-item>
                            <el-descriptions-item label="订单状态">
                                <div v-if="orderInfo.status == '0'">
                                    <el-tag class="style1" size="mini" type="danger">没有支付</el-tag>
                                </div>
                                <div v-if="orderInfo.status == '1'">
                                    <el-tag class="style1" size="mini" type="success">已经支付</el-tag>
                                </div>
                            </el-descriptions-item>
                            <el-descriptions-item label="订单创建时间">{{ orderInfo.gmtCreate }}</el-descriptions-item>
                            <el-descriptions-item label="订单更新时间">{{ orderInfo.gmtModified }}</el-descriptions-item>
                        </el-descriptions>
                    </div>
                </div>

                <div>
                    <el-button @click="previous">返回上一页</el-button>
                    <div v-if="this.orderInfo.status=='0'">
                        <el-button :disabled="false" style="float:right" type="primary" @click="toPay">前往支付订单</el-button>
                    </div>
                </div>
            </div>
        </template>

    </div>
</template>
  
<script>
import order from '@/api/order'

export default {
    data() {
        return {
            orderId: '',//订单id
            orderInfo: {},
        }
    },
    created() {
        if (this.$route.params && this.$route.params.id) {
            this.orderId = this.$route.params.id;
            // 调用方法根据订单id查询订单信息
            this.getOrderInfo(this.orderId);
        }
    },
    methods: {
        // 点击返回上一页执行的方法
        previous() {
            this.$router.go(-1)
        },
        // 点击前往支付订单执行的方法
        toPay() {

            this.$router.push({ path: "/order/" + this.orderId });
        },
        getOrderInfo(orderId) {
            // 根据订单id获取订单信息
            order.getOrderById(orderId).then(response => {
                if (response.data.success) {
                    this.orderInfo = response.data.data.tOrder;
                    console.log("订单信息：" + this.orderInfo.status)
                }
            });
        }
    }
}
</script>

<style scoped>
.ccInfo {
    background: #f5f5f5;
    padding: 20px;
    overflow: hidden;
    border: 1px dashed #DDD;
    margin-bottom: 40px;
    position: relative;
}

.ccInfo img {
    background: #d6d6d6;
    width: 500px;
    height: 278px;
    display: block;
    float: left;
    border: none;
}

.ccInfo .main {
    margin-left: 520px;
}

.ccInfo .main h2 {
    font-size: 28px;
    margin-bottom: 30px;
    line-height: 1;
    font-weight: normal;
}

.ccInfo .main p {
    margin-bottom: 10px;
    word-wrap: break-word;
    line-height: 24px;
    max-height: 48px;
    overflow: hidden;
}

.ccInfo .main p {
    margin-bottom: 10px;
    word-wrap: break-word;
    line-height: 24px;
    max-height: 48px;
    overflow: hidden;
}

.ccInfo .main h3 {
    left: 540px;
    bottom: 20px;
    line-height: 1;
    font-size: 28px;
    color: #d32f24;
    font-weight: normal;
    position: absolute;
}
</style>